package com.rico.service;

import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class TestSeataService {

    @GlobalTransactional(timeoutMills = 300000, name = "order-tx")
    public String testSeata() {
        /**
        log.info("====== order Service Begin ... xid: " + RootContext.getXID());
        //订单入库
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn(UUID.randomUUID().toString().replace("-",""));
        long time = System.currentTimeMillis();
        orderEntity.setCreateTime(time);
        orderEntity.setUpdateTime(time);
        orderEntity.setAmount(orderPrice);
        orderMapper.insert(orderEntity);
        String res = "订单创建成功，订单总价为" + orderPrice + "（元）";
        //发货
        String address = "西安市";
        boolean shipFlag = shipRemote.shipOrder(address);
        res += ",现在进行发货，发货地址为："+address+",发货成功状态为："+shipFlag;

        //送会员
        Boolean present = memberRemote.present("张三");
        res += ",现在为期赠送会员，赠送结果成功状态为：" + present;
        return res;
         **/
        return "";
    }
}
